package io.sage.modules.query.enums;

import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum BWeatherEnum {

    CLEAR_DAY("CLEAR_DAY", "晴天"),
    CLEAR_NIGHT("CLEAR_NIGHT", "晴夜"),
    PARTLY_CLOUDY_DAY("CLEAR_DAY", "多云"),
    PARTLY_CLOUDY_NIGHT("PARTLY_CLOUDY_NIGHT", "多云"),
    CLOUDY("CLOUDY", "阴"),
    RAIN("RAIN", "雨"),
    SNOW("SNOW", "雪"),
    HAZE("HAZE", "雾霾沙尘"),
    WIND("WIND", "风");

    private String code;
    private String message;


    /**
     * 根据code获取message
     * @param code
     * @return
     */
    public static String getMessage(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for (BWeatherEnum examEnum : BWeatherEnum.values()){
            if (code.equals(examEnum.getCode()) || code == examEnum.getCode()){
                return examEnum.getMessage();
            }
        }
        return null;
    }

    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
        BWeatherEnum[] values = BWeatherEnum.values();
        for (BWeatherEnum questionGradeEnum : values) {
            HashMap<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put("code", questionGradeEnum.getCode());
            hashMap.put("message", questionGradeEnum.getMessage());
            returnList.add(hashMap);
        }
        return returnList;
    }

    private BWeatherEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }

}
